package com.springbootblog.dao;

import com.springbootblog.dao.sqlBuilder.ChatSqlBuilder;
import com.springbootblog.dao.sqlBuilder.FooterSqlBuilder;
import com.springbootblog.dao.sqlBuilder.UserSqlBuilder;
import com.springbootblog.pojo.ChatRecord;

import java.util.List;

import com.springbootblog.pojo.User;
import org.apache.ibatis.annotations.*;

public interface ChatRecordDao
{
    /**
     * 将未读消息改成已读
     * @param from_user_id
     * @param to_user_id
     * @return
     */
    @UpdateProvider(type = ChatSqlBuilder.class, method = "updateChatRecordStatus")
    Integer updateChatRecordStatus(@Param("from_user_id")String from_user_id,@Param("to_user_id") String to_user_id);

    /**
     * 查聊天记录列表
     * @param from_user_id
     * @param to_user_id
     * @return
     */
    @SelectProvider(type = ChatSqlBuilder.class, method = "getChatRecordList")
    List<ChatRecord> getChatRecordList(@Param("from_user_id") String from_user_id,@Param("to_user_id") String to_user_id);

    @SelectProvider(type = ChatSqlBuilder.class, method = "getUnReadNumber")
    Integer getUnReadNumber(@Param("to_user_id") String to_user_id, @Param("user_id") String user_id);

    /**
     * 添加聊天记录
     * @param chatRecord
     * @return
     */
    @InsertProvider(type = ChatSqlBuilder.class, method = "addChatRecord")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    Integer addChatRecord(ChatRecord chatRecord);

}